<template>
  <div class="container">
    <div class="app-container">
      <el-row style="margin-left: 20px;">
        <span style="size: 14px;">员工姓名：</span>
        <el-input v-model="pageParams.name" size="mini" placeholder="请输入员工姓名" style="width: 200px;margin-top: 20px;" />
        <el-button type="primary" size="mini" style="margin-left: 20px;" @click="search">查询</el-button>
      </el-row>
      <el-button type="primary" style="margin: 20px;" size="mini">添加员工</el-button>
      <el-table :data="list" style="width: 100%; margin-top: 20px;">
        <el-table-column type="index" label="序号" width="80" />
        <el-table-column align="center" prop="name" label="员工姓名" />
        <el-table-column align="center" prop="userName" label="登录账号" />
        <el-table-column align="center" prop="phonenumber" label="联系方式" />
        <el-table-column align="center" prop="roleName" label="角色" />
        <el-table-column align="center" prop="status" label="状态">
          <template v-slot="{ row }">
            {{ row.status ===1 ? '启用' : '未启用' }}
          </template>
        </el-table-column>
        <el-table-column align="center" prop="createTime" label="添加时间" />
        <el-table-column align="center" label="操作">
          <template>
            <el-button type="text" size="mini">编辑</el-button>
            <el-button type="text" size="mini">删除</el-button>
            <el-button type="text" size="mini">重置密码</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-row type="flex" justify="end">
        <el-pagination
          :current-page="pageParams.page"
          :page-sizes="[10, 20, 50, 100]"
          :page-size="pageParams.pagesize"
          layout="total, sizes, prev, pager,next,jumper "
          :total="total"
        />
      </el-row>
    </div>
  </div>
</template>
<script>
import { getEmployeeListAPI } from '@/api'

export default {
  name: 'Employee',
  data() {
    return {
      list: [],
      pageParams: {
        name: '',
        page: 1,
        pagesize: 10,
        total: 0
      }
    }
  },
  created() {
    this.getEmployeeList()
  },
  methods: {
    async getEmployeeList() {
      const { rows, total } = await getEmployeeListAPI(this.pageParams)
      this.list = rows
      this.total = total
    },
    async search() {
      await this.getEmployeeList()
    }
  }
}
</script>
